import time

from YkLX.Yklx_1.Base import Base
from selenium.webdriver.common.by import By
from selenium import webdriver
class Page(Base):
    headerLogin_loc=(By.CLASS_NAME,'headerLogin')
    def headerLogin(self):
        self.click(self.headerLogin_loc)
    dy1_loc=(By.XPATH,'/html/body/div/form/div/div/div/div/div[1]/div[1]/a[1]')
    def dy1(self):
        return self.text(self.dy1_loc)

    userName_loc=(By.ID,'userName')
    def userName(self,username):
        self.send_keys(self.userName_loc,username)

    password_loc=(By.ID,'password')
    def password(self,password):
        self.send_keys(self.password_loc,password)

    save_loc=(By.ID,'save')
    def save(self):
        self.click(self.save_loc)

    bindSub_loc=(By.ID,'bindSub')
    def bindSub(self):
        self.click(self.bindSub_loc)

    wd_loc=(By.ID,'wd')
    def wd(self):
        self.send_keys(self.wd_loc,'梦之蓝')
        self.key_enter(self.wd_loc)
    shangp_loc=(By.XPATH,'//img[@src="https://img07.jiuxian.com/2023/0224/6d8be8c068b24cf68973fdc409914ba14.jpg"]')
    def shangp(self):
        self.click(self.shangp_loc)

    addToCartForDetail_loc=(By.ID,'addToCartForDetail')
    def addToCartForDetail(self):
        self.click(self.addToCartForDetail_loc)
    chakan_loc=(By.XPATH,'/html/body/div[2]/div/div[2]/ul/li[3]/a')
    def chakan(self):
        self.click(self.chakan_loc)
    jiesuan_loc=(By.XPATH,'//*[@id="cart_container"]/div[3]/div[3]/a[1]')
    def jiesuan(self):
        self.click(self.jiesuan_loc)
    





    def test_jiuxian(self,username,password):
        self.headerLogin()
        time.sleep(3)
        print(self.dy1())
        assert '帐号登录' == str(self.dy1())
        time.sleep(3)
        self.userName(username)
        self.password(password)
        time.sleep(8)
        self.save()
        self.jietu()
        time.sleep(2)
        self.bindSub()
        self.driver.implicitly_wait(10)
        self.wd()
        self.shangp()
        self.qiehuan()
        time.sleep(3)
        self.addToCartForDetail()
        self.chakan()
        self.qiehuan()
        time.sleep(3)
        self.jiesuan()
        time.sleep(5)





        






